<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Country extends Model
{
  /**
   * Insert validation rules.
   *
   * @var array
   */
  public static $insertRules = [
    'iso_639_1' => 'required|max:2|unique:countries',
    'name' => 'required|max:255',
    'from' => 'nullable|date',
    'to' => 'nullable|date',
    'active' => 'nullable|boolean',
  ];

  /**
   * Update validation rules.
   *
   * @var array
   */
  public static $updatetRules = [
    'iso_639_1' => 'nullable|max:2|unique:countries',
    'name' => 'nullable|max:255',
    'from' => 'nullable|date',
    'to' => 'nullable|date',
    'active' => 'nullable|boolean',
  ];
  /**
   * The attributes that are mass assignable.
   *
   * @var array
   */
  protected $fillable = [
    'iso_639_1',
    'name',
    'from',
    'to',
    'active',
  ];

  /**
   * The attributes excluded from the model's JSON form.
   *
   * @var array
   */
  protected $hidden = [];

  /**
   * The attributes that should be cast to native types.
   *
   * @var array
   */
  protected $casts = [
    'from' => 'datetime',
    'to' => 'datetime',
  ];

  /**
   * Relationship with locales.
   */
  public function locales()
  {
    return $this->hasMany(Locale::class);
  }

  /**
   * Relationship with regions.
   */
  public function regions()
  {
    return $this->hasMany(Region::class);
  }
}
